package com.flowCloud.web.controller.tbl_user;

import com.flowCloud.config.log.SystemControllerLog;
import com.flowCloud.result.LayDatas;
import com.flowCloud.result.ResultModel;
import com.flowCloud.result.ResultTools;
import com.flowCloud.web.controller.tbl_user.vo.*;
import com.flowCloud.web.service.tbl_user.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flowCloud.web.bean.*;

import java.util.List;

/**
 * @Author: 系统自动生成
 * @Date: 2021-01-13
 * @Description: TblUserController 控制层
 */
@Slf4j
@RestController
@RequestMapping("tblUserCon")
public class TblUserController {

    @Autowired
    private TblUserService tblUserService;

    /**
     * @Description: 查询一条信息
     * @Author: 系统自动生成
     * @Date: 2021-01-13
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblUserCon】查询一条信息",type = "info")
    @GetMapping(value = "/getInfoByParam")
    public ResultModel getInfoByParam(GetInfoByParamVo vo){
        log.info("【tblUserCon】查询一条信息 [tblUserCon/getInfoByParam] 接口");
        try {
            TblUserBean infoByParam = tblUserService.getInfoByParam(vo);
            return ResultTools.success(infoByParam);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblUserCon 查询一条信息 ：%s",e.getMessage()));
            return ResultTools.fail("查询失败！");
        }
    }

    /**
     * @Description: 查询多条信息
     * @Author: 系统自动生成
     * @Date: 2021-01-13
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblUserCon】查询多条信息",type = "info")
    @GetMapping(value = "/getInfoListByParam")
    public ResultModel getInfoListByParam(GetInfoListByParamVo vo){
        log.info("【tblUserCon】查询多条信息 [tblUserCon/getInfoListByParam] 接口");
        try {
            List<TblUserBean> infoListByParam = tblUserService.getInfoListByParam(vo);
            return ResultTools.success(infoListByParam);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblUserCon 查询多条信息 ：%s",e.getMessage()));
            return ResultTools.fail("查询失败！");
        }
    }

    /**
     * @Description: 分页查询
     * @Author: 系统自动生成
     * @Date: 2021-01-13
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblUserCon】分页查询",type = "info")
    @GetMapping(value = "/getPageInfo")
    public ResultModel getPageInfo(GetPageInfoVo vo){
        log.info("【tblUserCon】分页查询 [tblUserCon/getPageInfo] 接口");
        try {
            LayDatas pageInfo = tblUserService.getPageInfo(vo);
            return ResultTools.success(pageInfo);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblUserCon 分页查询 ：%s",e.getMessage()));
            return ResultTools.fail("查询失败！");
        }
    }

    /**
     * @Description: 添加
     * @Author: 系统自动生成
     * @Date: 2021-01-13
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblUserCon】添加",type = "info")
    @PostMapping(value = "/add")
    public ResultModel add(AddVo vo){
        log.info("【tblUserCon】添加 [tblUserCon/add] 接口");
        try {
            int add = tblUserService.add(vo);
            if(add>0){
                return ResultTools.success("添加成功！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblUserCon 添加 ：%s",e.getMessage()));
        }
        return ResultTools.fail("添加失败");
    }

    /**
     * @Description: 修改
     * @Author: 系统自动生成
     * @Date: 2021-01-13
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblUserCon】修改",type = "info")
    @PostMapping(value = "/update")
    public ResultModel update(UpdateVo vo){
        log.info("【tblUserCon】修改 [tblUserCon/update] 接口");
        try {
            int update = tblUserService.update(vo);
            if(update>0){
                return ResultTools.success("修改成功！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblUserCon 修改 ：%s",e.getMessage()));
        }
        return ResultTools.fail("修改失败！");
    }


    /**
     * @Description: 删除
     * @Author: 系统自动生成
     * @Date:  2021-01-13
     * @param vo
     * @return: com.jsb.api.result.ResultModel
     */
    @SystemControllerLog(operation = "【tblUserCon】删除",type = "info")
    @PostMapping(value = "/delete")
    public ResultModel delete(DeleteVo vo){
        log.info("【tblUserCon】删除 [tblUserCon/delete] 接口");
        try {
            int delete = tblUserService.delete(vo);
            if(delete>0){
                return ResultTools.success("删除成功！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(String.format("【异常错误】tblUserCon 删除 ：%s",e.getMessage()));
        }
        return ResultTools.fail("删除失败！");
    }
}
